﻿using Game.Common;
using Game.Map.Internal;

namespace Game.Map
{
    public static class Factory
    {
        public static IGameMap Create()
        {
            var size = GameParameters.SquareNumber;
            return Create(size, size);
        }

        public static IGameMap Create(
            int width,
            int height)
        {
            var map = new GameMap(width, height);
            CreateViews(map);
            return map;
        }

        internal static void CreateViews(GameMap map)
        {
            GameDebug.Assert(map.Views == null);
            map.Views = new ViewCollection
            {
                MapViewFactory.CreateView(map, AiPlayer.Player), 
                MapViewFactory.CreateView(map, HumanPlayer.Player)
            };

            foreach (var view in map.Views)
            {
                MapViewFactory.FireSetupView(view);
            }

        }
    }
}
